

// 打开文件
function openfile(filename) {
	oframe.Open(filename);
}

// 关闭文件
function closefile() {
	oframe.close();
}

// 另存文件
function save(filename) {

	oframe.Save(filename, true);
}

// 正常打印
function print() {
	var flag = oframe.ActiveDocument.PrintFormsData;
	oframe.ActiveDocument.PrintFormsData = false;
	oframe.ActiveDocument.PrintOut(true);
	oframe.ActiveDocument.PrintFormsData = flag;
}
// 套打，只打域对象
function print2() {
	var flag = oframe.ActiveDocument.PrintFormsData;
	oframe.ActiveDocument.PrintFormsData = true;
	oframe.ActiveDocument.PrintOut(true);
	oframe.ActiveDocument.PrintFormsData = flag;
}

// 打印预览
function preview() {
	var form = oframe.ActiveDocument.FormFields;
	alert(form.count);
	for (var i = form.count - 1; i >= 0; i--) {
		var item = form.Item(i + 1);
		alert(item.Result);
	}
	oframe.PrintPreview();
}

// 导出文件
function output() {
	oframe.ShowDialog(3);
}

// 放大
function zoomin() {
	if (zoom < 500) {
		zoom = Math.round(zoom * 1.2);
		oframe.ActiveDocument.Application.ActiveWindow.Zoom = zoom;
	}
}

// 缩小
function zoomout() {
	if (zoom > 20) {
		zoom = Math.round(zoom / 1.2);
		oframe.ActiveDocument.Application.ActiveWindow.Zoom = zoom;
	}
}

// 执行宏
function executeMacro(macroname) {
	oframe.ActiveDocument.Application.Run(macroname);
}

function showbookmark() {
	var showmk = oframe.ActiveDocument.Application.ActiveWindow.View.ShowBookmarks;
	oframe.ActiveDocument.Application.ActiveWindow.View.ShowBookmarks = !showmk;
}

// 更新域对象，向模板中插入数据
function updateForm(datas) {
	if (datas) {
		if (!datas.isprotect) {
			var form = oframe.ActiveDocument.FormFields;
			for (var i = form.count - 1; i >= 0; i--) {
				var item = form.Item(i + 1);
				var data = datas[item.Name];
				if (data)
					item.Result = data;
			}

			//oframe.ActiveDocument.Protect(3);
			datas.isprotect = true;

		}

	}

}
